package mini.statement;


import java.util.HashMap;
import java.util.LinkedList;

import mini.Proc;
import mini.StatementList;
import mini.expr.Expr;

public class WhileStatement extends Statement {


    private Expr expr;
    private StatementList stmtlist;

    public WhileStatement(Expr e, StatementList list) {
        expr = e;
        stmtlist = list;
    }

    public void eval(HashMap<String, Integer> nametable, HashMap<String, Proc> functiontable, LinkedList var) throws Exception {
        while (expr.eval(nametable, functiontable, var) > 0) {
            stmtlist.eval(nametable, functiontable, var);
        }
    }
}
